<%@ Page Language="C#" EnableViewState="false" ValidateRequest="false" AutoEventWireup="true" 
	 MasterPageFile="~/App_ThemeMasters/NoStyle/AdminOneColumnLayout.Master" Inherits="Syrinx.Gui.AspNet.Ajax.NitobiBasePage" %>
<%@ Register Assembly="Swaf.Gui.AspNet2" Namespace="Swaf.Gui.AspNet2" TagPrefix="swf" %>
<%@ Register Assembly="ScsAspNet" Namespace="Syrinx.Gui.AspNet.Ajax" TagPrefix="saj" %><%@ Register Assembly="NitobiControls" Namespace="Nitobi" TagPrefix="ntb" %>
<%@ Register Assembly="ScsAspNet" Namespace="Articles.Gui.AspNet" TagPrefix="art" %>
<%@ Register Assembly="ScsAspNet" Namespace="Calendars.Gui.AspNet" TagPrefix="cal" %>

<!--#include file="~/SiteControls/RegisterStandardControls.txt"-->
<!--#include file="../SiteControls/StandardAdminHeaderPageContent.inc"-->
<!--#include file="../SiteControls/StandardFooterPageContent.inc"-->

<script runat="server">
	public string TitleFormat = "$company.name$ - Calendar Management";
</script>

<asp:Content ContentPlaceHolderID="header1" runat="server">
	<link rel="stylesheet" type="text/css" href="/jquery.mbContainerPlus.2.0/css/mbContainer.css" title="style"  media="screen">
	<script type="text/javascript" src="/jquery.mbContainerPlus.2.0/inc/ui.core.min.js"></script>
	<script type="text/javascript" src="/jquery.mbContainerPlus.2.0/inc/ui.draggable.min.js"></script>
	<script type="text/javascript" src="/jquery.mbContainerPlus.2.0/inc/ui.resizable.min.js"></script>
	<script type="text/javascript" src="/jquery.mbContainerPlus.2.0/inc/jquery.metadata.js"></script>
	<script type="text/javascript" src="/jquery.mbContainerPlus.2.0/inc/mbContainer.js"></script>
</asp:Content>

<asp:Content ID="c1" ContentPlaceHolderID="title" runat="server">
	<%SecurityPrivilege = "AppFunctions.ManageArticles"; %>
	<h1 ID="_ImgCacheLibLbl" runat="server">Calendar Management</h1>
    <swf:BizProc ID="calendars" runat="server" FactoryName="Calendars">
		<ParentBizProc id="loginBP" />
    </swf:BizProc>
	<swf:BizProc ID="cal" runat="server" FactoryName="CalView">
		<State calendarTemplate="GenEventCal"  />
		<ParentBizProc id="calendars" fieldName="id" dataId="pid" />
	</swf:BizProc>
	<swf:BizProc ID="calEvents" runat="server" FactoryName="CalEvents">
		<ParentBizProc id="calendars" fieldName="id" dataId="pid" />
	</swf:BizProc>
	<swf:BizProc ID="calEvtTypes" runat="server" FactoryName="CalEventTypes">
		<ParentBizProc id="calendars" fieldName="id" dataId="pid" />
	</swf:BizProc>
	<script type="text/javascript" src="/js/ClientCalScript.js"></script>
</asp:Content>

<asp:Content ID="c2" ContentPlaceHolderID="trails" runat="server">
<script type="text/javascript">
function toggleTabs(cId,c1, dId){
	for(i=1; ;i++){
		var a = document.getElementById(cId + i);
		var b = document.getElementById(dId + i);
		if(a==null || a=='')
			break;
			
		if(i==c1){
			a.className = 'currenttab';
			b.style.display = 'block';
		}
		else{
			a.className='';
			b.style.display = 'none';
		}
	}
}
</script>

	<div style="float:right">
	<table><tr><td valign="bottom">
	<div class="HelpBtnArea">
		<asp:HyperLink runat="server" ID="_pageHelp" NavigateUrl="../std/Help.aspx?helpid=CalendarManagementHelp" Target="help">Help</asp:HyperLink>
	</div>
	 </td></tr></table>
	 </div>
	 <div class="clearer"></div>
</asp:Content>

<asp:Content ID="c3" ContentPlaceHolderID="mainContent" runat="server">
<script type="text/javascript">
function setCalendarState(stateEl)
{
	try {
		var title = stateEl.getAttribute('title');
		var body = stateEl.getAttribute('body');
		if(body != null && body != '')
		{
			if ($('#' + this.id + ' .CalTitle').length != 0) {
				$('#' + this.id + ' .CalTitle').replaceWith(title);
				$('#' + this.id + ' .CalBody').replaceWith(body);
			}
			else {
				$('#' + this.id).replaceWith(title + body);
				
			}
		}
		setCalSizeNow();
		var script = stateEl.getAttribute('script');
		if(script != null && script.length > 0)
			eval(script);
	}catch(e){}	
}

	function manageDayView(daySel, doToggle) {
		var ds = $(daySel);
		ds.parent().appendTo($("body").width() < 1000 ? "#daybottom" : "#dayright");
		if(doToggle)
			daySel.mb_toggleDraggable();
		setCalSizeNow();
	}
	$(window).resize(function() {
	var dd = $("#dayAreaWin");
		
		$("#dayAreaWin").parent().appendTo($("body").width() < 1000 ? "#daybottom" : "#dayright");
	});
	
	$(document).ready(function() {
		$("#calEvtDet").resizable({ minHeight: 350, minWidth: 425,
			resize: function(event, ui) {
				var e = $("#ctl00_mainContent_ArticleTranslationDisplay2_baseBody___Frame");
				e.height($("#calEvtDet").height() - ($("#calEvtDetN").height() + 20 + 15));
			}
		});
		$("#calDet").resizable({ minHeight: 350, minWidth: 425,
			resize: function(event, ui) {
				var e = $("#ctl00_mainContent_cald2_baseBody___Frame");
				e.height($("#calDet").height() - ($("#calDetN").outerHeight(true) + 15) );
			}
		});
		
		manageDayView($("#dayAreaWin"));

	});
</script>
	<table class="adminPageWidth" border="0" ><tr><td >
    <div class="SimpleVerticalBg"> 
	    <saj:Grid ID="articleList1Display" runat="server" Width="250px" Height="600px" ShowToolbar="false"
		    ParentBizProcIds="calendars" Mode="LiveScrolling" Resizable="Both" >
		    <Columns>
			    <ntb:KeyColumn DataField="id" />
			    <ntb:BoundColumn DataField="depthName" HeaderText="Name" width="315" />
			    <ntb:BoundColumn DataField="x" Width="40" />
			    <ntb:BoundColumn DataField="x" Width="40" />
		    </Columns>
	    </saj:Grid>
    </div>
</td><td class="adminRightContentWidth">
		<div class="tabs">
			<ul>
				<li id="t1" class="currenttab"><div class="firstTab"><swf:DivLayers runat="server" ID="tl1" SkinID="Tab"><asp:HyperLink onclick="toggleTabs('t','1','ta');setCalSizeNow();" runat="server" ID="_cmpMngrTab1" Text="Calendar" NavigateUrl="javascript:;" /></swf:DivLayers></div></li>
				<li id="t3"><swf:DivLayers runat="server" ID="tl3" SkinID="Tab"><asp:HyperLink runat="server" onclick="toggleTabs('t','3','ta');" ID="_dtlTab3" Text="Details" NavigateUrl="javascript:;" /></swf:DivLayers></li>
				<li id="t2"><swf:DivLayers runat="server" ID="tl2" SkinID="Tab"><asp:HyperLink runat="server" onclick="toggleTabs('t','2','ta');" ID="_pubInfLbl" Text="Events" NavigateUrl="javascript:;" /></swf:DivLayers></li>
				<li id="t4"><div class="lastTab"><swf:DivLayers runat="server" ID="tl4" SkinID="Tab"><asp:HyperLink runat="server" onclick="toggleTabs('t','4','ta');" ID="_cmpMngrTab4" Text="Event Types" NavigateUrl="javascript:;" /></swf:DivLayers></div></li>
			</ul>
		</div>
	<swf:DivLayers ID="mdl1" runat="server" SkinID="MainTabArea">
		<div id="ta1">
            <saj:ActionButton ID="p1" runat="server" Actions="cal.MovePrev" Text="Prev" />
            <saj:ActionButton ID="n1" runat="server" Actions="cal.MoveNext" Text="Next" />		
            <table width="100%" border="0"><tr><td width="100%">
            <div style="max-width:900px;min-width:300px;">
			<saj:CalendarBizObjListDisplay ID="calV1" runat="server" ParentBizProcIds="cal" 
				NumRanges="1" CalendarFormat="Month" FirstDayOfWeek="Monday" OnDateClick="$('#dayAreaWin').mb_open();" />
			</div>
			</td><td id="dayright">
				<saj:CalendarBizObjListDisplay  ID="calV2" runat="server" ParentBizProcIds="cal"
					 NumRanges="1" CalendarFormat="Day" IsInFlow="false" />
			</td></tr>
			<tr><td colspan="2" id="daybottom">
			</td></tr>
			</table>



		</div>
		<div id="ta2" style="display:none;">
			<div style="float:left">
			<saj:Grid ID="Grid1" runat="server" Width="450px" Height="180px" ShowToolbar="false"
				ParentBizProcIds="calEvents" Mode="LiveScrolling" Resizable="Both" >
				<Columns>
					<ntb:KeyColumn DataField="id" />
					<ntb:TextColumn DataField="title" HeaderText="Name" width="200" MaxLength="200" ReadOnly="false" />
					<ntb:DateColumn DataField="startTime" HeaderText="Start" Width="125" ReadOnly="false" Mask="M/dd/yyyy hh:mm" />
					<ntb:DateColumn DataField="endTime" HeaderText="End" Width="125" ReadOnly="false"  Mask="M/dd/yyyy hh:mm" />
				</Columns>
			</saj:Grid>
			</div>
			<div id="calEvtDet" class="ui-widget-content" style="padding: 0.5em;float:left;">
				<div id="calEvtDetN">
					<span class="button6"><saj:ActionButton runat="server" ID="ActionButton1" Actions="calEvents.UpdateBizObj" Text="Update" /></span>
					<span class="button1"><saj:ActionButton runat="server" ID="ActionButton2" Actions="calEvents.AddBizObj" Text="Add" /></span>
					<span class="button2"><saj:ActionButton runat="server" ID="ActionButton3" Actions="calEvents.CancelEdits" Text="Cancel" /></span>
					<span class="button5"><saj:ActionButton runat="server" ID="ActionButton4" Actions="calEvents.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/></span>
					<art:ArticleTranslationDisplay runat="server" ID="cdet1"
						ParentBizProcIds="calEvents" AlwaysRefreshOnAjaxEvent="True"
						TranslationTemplate="Articles.Gui.AspNet.ArticleTranslationRWDisplay"
						ReadOnlyTemplate="Calendars.Gui.AspNet.CalendarEventRWDisplay"
						>
						<macros imageRes="Thumbnail" />
					</art:ArticleTranslationDisplay>
					<art:ArticleTranslationDisplay runat="server" ID="cdet2" ParentBizProcIds="calEvents"
						ReadOnlyTemplate="Calendars.Gui.AspNet.CalendarEventRWDisplay-LocationOnly" />
				</div>
				<art:ArticleTranslationDisplay runat="server" ID="cdet3" ParentBizProcIds="calEvents"
					ReadOnlyTemplate="Calendars.Gui.AspNet.CalendarEventRWDisplay-BodyOnly" />
				<div style="height:15px;"></div>
		    </div>
		</div>
		<div id="ta3" style="display:none;">
			<div id="calDet" class="ui-widget-content" style="padding: 0.5em;">
				<div id="calDetN">
					<div class="ButtonArea">
						<saj:ActionButton runat="server" ID="updateBtn1" Actions="calendars.UpdateBizObj" Text="Update" />
						<saj:ActionButton runat="server" ID="addBtn" Actions="calendars.AddBizObj" Text="Add" />
						<saj:ActionButton runat="server" ID="cancelBtn" Actions="calendars.CancelEdits" Text="Cancel" />
						<saj:ActionButton runat="server" ID="deleteBtn" Actions="calendars.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/>
					</div>
					<art:ArticleTranslationDisplay runat="server" ID="cald1"
						ParentBizProcIds="calendars" 
						TranslationTemplate="Articles.Gui.AspNet.ArticleTranslationRWDisplay"
						ReadOnlyTemplate="Calendars.Gui.AspNet.CalendarRWDisplay"
						EditableTemplate="Calendars.Gui.AspNet.CalendarRWDisplay" >
						<macros imageRes="Thumbnail" />
					</art:ArticleTranslationDisplay>
				</div>
					<art:ArticleTranslationDisplay runat="server" ID="cald2"
						ParentBizProcIds="calendars" 
						ReadOnlyTemplate="Calendars.Gui.AspNet.CalendarRWDisplay-BodyOnly" />
				<div style="height:15px;"></div>
	        </div>
        </div>
        <div id="ta4" style="display:none;">
			<saj:Grid ID="evtGrid" runat="server" Width="505px" Height="400px" RowHeight="30" 
				AllowAddRow="true" AllowDeleteRow="true" AllowSorting="false" ShowToolbar="true"
				ParentBizProcIds="calEvtTypes" Mode="LiveScrolling" Resizable="Both" >
				<Toolbars>
					<ntb:GridToolbar Title="LeftSide">
						<ntb:AddButtonItem />
						<ntb:DeleteButtonItem />
						<ntb:RefreshButtonItem />
						<ntb:SeparatorItem />
						<ntb:ButtonItem Id="img" ImageUrl="/images/mapIcon.gif" Tooltip="Set Event Type Map Pin Image" 
							Click="var bizObj = window.showModalDialog('/popups/PickImagePopup.aspx',{imageFieldName:'mapImageUrl', bizObj: getGridRowInfo('ctl00_mainContent_evtGrid')},'dialogWidth:400px; dialogHeight:400px; center:yes; resizable: yes; help: no ');updateGridRowInfo('ctl00_mainContent_evtGrid',bizObj);" />
						<ntb:SeparatorItem />
						<ntb:SaveButtonItem Click="calEvtTypesBizProc.triggerEvent('ctl00_mainContent_updateEvtType','UpdateBizObj');" />
						<ntb:SeparatorItem />
						<ntb:TotalRowsInfoItem CssStyle="margin-top:4px;float:left;">
							<div style='padding-left:10px;'>Total Address Types <b>{0}</b></div>
						</ntb:TotalRowsInfoItem>
					</ntb:GridToolbar>
				</Toolbars>
				<Columns>
					<ntb:KeyColumn DataField="id" />
					<ntb:TextColumn DataField="title" HeaderText="Name" width="173" MaxLength="200" ReadOnly="false" />
					<ntb:CheckboxColumn DataField="allowEnrollment" HeaderText="Enroll" Width="40" ReadOnly="false" />
					<ntb:ImageColumn DataField="mapImageUrl" HeaderText="Map Pin" width="55" />
					<ntb:TextColumn DataField="backColor" HeaderText="Background" Width="80" MaxLength="15" ReadOnly="false" />
					<ntb:TextColumn DataField="foreColor" HeaderText="Foreground" Width="80" MaxLength="15" ReadOnly="false" />
					<ntb:CheckboxColumn DataField="useColorForDateArea" HeaderText="Primary" Width="60" ReadOnly="false" />
				</Columns>
			</saj:Grid>
			<span style="display:none">
				<saj:ActionButton runat="server" ID="updateEvtType" Actions="calEvtTypes.UpdateBizObj" Text="Update" />
				<saj:ActionButton runat="server" ID="ActionButton6" Actions="calEvtTypes.AddBizObj" Text="Add" />
				<saj:ActionButton runat="server" ID="ActionButton7" Actions="calEvtTypes.CancelEdits" Text="Cancel" />
				<saj:ActionButton runat="server" ID="ActionButton8" Actions="calEvtTypes.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/>
			</span>
        </div>
    </swf:DivLayers>
</td></tr></table>    
</asp:Content>
